// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterdemo/common/calc.dart';
import 'package:flutterdemo/components/avatar.dart';
import 'package:flutterdemo/components/icon_right.dart';
import 'package:flutterdemo/components/img.dart';

class MePage extends StatefulWidget {
  MePage({Key? key}) : super(key: key);

  @override
  _MePageState createState() => _MePageState();
}

class _MePageState extends State<MePage> with AutomaticKeepAliveClientMixin {
  @override
  bool get wantKeepAlive => true;

  // 头部内容
  Widget _headerW() {
    return Ink(
        padding: EdgeInsets.all(Calc.width(30)),
        decoration: BoxDecoration(color: Color.fromRGBO(255, 255, 255, 1)),
        child: InkWell(
          onTap: (){
            Navigator.pushNamed(context, "personalChange");
          },
          child: Row(
            children: [
              Avatar(
                "https://shangguling-live.oss-cn-shenzhen.aliyuncs.com/uploads/20210728/6a4847377d8b18066ac03094f75e23ca.png",
                size: Calc.width(140),
              ),
              SizedBox(
                width: Calc.width(20),
              ),
              Expanded(
                flex: 1,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      "網名",
                      style: TextStyle(fontSize: Calc.width(38)),
                    ),
                    SizedBox(
                      height: Calc.width(20),
                    ),
                    Text(
                      "個性簽名",
                      style: TextStyle(color: Colors.grey),
                    ),
                  ],
                ),
              ),
              Icon(
                Icons.arrow_forward_ios,
                size: Calc.width(36),
                color: Colors.grey,
              )
            ],
          ),
        ));
  }

  // 下面每一项
  Widget _iconItem(Icon icon, String name, String routeName) {
    return Ink(
      color: Colors.white,
      child: InkWell(
        onTap: () {
          Navigator.pushNamed(context, routeName);
        },
        child: Container(
          padding: EdgeInsets.all(Calc.width(30)),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              icon,
              SizedBox(
                width: Calc.width(20),
              ),
              Expanded(
                flex: 1,
                child: Text(name),
              ),
              Icon(
                Icons.arrow_forward_ios,
                size: Calc.width(36),
                color: Colors.grey,
              )
            ],
          ),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Color.fromRGBO(233, 233, 233, 1),
        body: Container(
          child: ListView(
            physics: BouncingScrollPhysics(),
            children: [
              _headerW(),
              SizedBox(
                height: Calc.width(20),
              ),
              IconRight(
                icon: Icon(Icons.settings, color: Colors.blue),
                name: "设置",
                routeName: "setting",
              ),
              SizedBox(
                height: Calc.width(20),
              ),
              IconRight(
                icon: Icon(
                  Icons.grade,
                  color: Colors.orange,
                ),
                name: "收藏",
                routeName: "collect",
              ),
              Divider(
                height: 0,
                color: Color.fromRGBO(200, 200, 200, 1),
              ),
              IconRight(
                icon: Icon(Icons.pets, color: Colors.blue),
                name: "浏览历史",
                routeName: "history",
              ),
              Divider(
                height: 0,
                color: Color.fromRGBO(200, 200, 200, 1),
              ),
              IconRight(
                icon: Icon(Icons.room, color: Colors.yellow),
                name: "收货地址",
                routeName: "address",
              ),
              Divider(
                height: 0,
                color: Color.fromRGBO(200, 200, 200, 1),
              ),
              IconRight(
                icon: Icon(Icons.upcoming, color: Colors.pink),
                name: "会员中心",
                routeName: "member",
              ),
              Divider(
                height: 0,
                color: Color.fromRGBO(200, 200, 200, 1),
              ),
              IconRight(
                icon: Icon(Icons.featured_play_list, color: Colors.green),
                name: "实名认证",
                routeName: "realName",
              ),
              SizedBox(
                height: Calc.width(20),
              ),
              IconRight(
                icon: Icon(Icons.laptop, color: Colors.red),
                name: "订单管理",
                routeName: "order",
              ),
            ],
          ),
        ));
  }
}
